package com.win.oauth.controller;


import com.fyl.controller.BaseController;
import com.fyl.core.advance.constant.enums.CommonResponseEnum;
import com.fyl.core.response.RS;
import com.win.oauth.entity.Task;
import com.win.oauth.service.ITaskService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author fyl
 * @since 2020-09-05
 */
@RestController
@RequestMapping("/oauth/task")
public class TaskController extends BaseController<ITaskService, Task> {

    @PostMapping({"/add"})
    public RS<Void> add(@RequestBody Task entity) {
        return this.baseService.save(entity) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }

    @PostMapping({"/update"})
    public RS<Void> update(@RequestBody Task entity) {
        return this.baseService.updateById(entity) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }

    @PostMapping({"/delete"})
    public RS<Void> delete(@RequestBody Collection<Long> idList) {
        return this.baseService.removeByIds(idList) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }
}
